const path = require('path')

module.exports = {
  publicPath: './',
  configureWebpack: function() {
    return {
      resolve: {
        alias: {
          vue$: 'vue/dist/vue.esm.js',
          '@views': path.resolve(__dirname, './src/views'),
        }
      }
    }
  },
  chainWebpack(config) {
    config.module
      .rule('scss')
      .test(/\.scss$/)

      .oneOf('normal')
      .use('sass-loader')
      .options({ sourceMap: true })
      .end()

      .use('scss')
      .before('sass-loader')
      .loader('resolve-url-loader')
      .end()
      .end()

      .oneOf('normal-modules')
      .use('sass-loader')
      .options({ sourceMap: true })
      .end()

      .use('scss')
      .before('sass-loader')
      .loader('resolve-url-loader')
      .end()
      .end()

      .oneOf('vue-modules')
      .use('sass-loader')
      .options({ sourceMap: true })
      .end()

      .use('scss')
      .before('sass-loader')
      .loader('resolve-url-loader')
      .end()
      .end()

      .oneOf('vue')
      .use('sass-loader')
      .options({ sourceMap: true })
      .end()

      .use('scss')
      .before('sass-loader')
      .loader('resolve-url-loader')
      .end()
      .end()

    config.module
      .rule('eslint')
      .use('eslint-webpack-plugin')
      .options({
        formatter: require('eslint-formatter-pretty')
      })
    config.plugins.delete('prefetch')
  }
}
